﻿@using Himall.Model;
@using Himall.Web.Areas.SellerAdmin.Models;

@model IEnumerable<LimitTimeMarketInfo>
@{
    List<SelectListItem> CateSelItem = (List<SelectListItem>)ViewBag.Cate;
    ViewBag.Title = "限时购";
}
<div class="topic">
    <div class="slide" id="slide">
        <ul class="slide-items">
            @foreach (var item in ((IEnumerable<SlideAdInfo>)ViewBag.Slide))
            {

                <li><a href="@item.Url" style="background-image:url(@item.ImageUrl)"></a></li>

            }
        </ul>
    </div>


    <div class="w cl">
        @if (CateSelItem.Count > 0)
        {
            <div class="ltcatebox cl" style="margin-top:20px">
                    <dl class="ltcate">
                        <dt>分类：</dt>
                        <dd class="@(CateSelItem.Count(d=>d.Selected==true)==0 ? "curr" : "")"><a href="@Url.Action("Home", "LimitTimeBuy", new { pageNo = 1, keywords = ViewBag.keywords, orderType = 2, orderKey = 1, catename="" })" onclick="">所有</a><b></b></dd>
                        @foreach (var _item in CateSelItem)
                        {
                            <dd class="@(_item.Selected ? "curr" : "")"><a href="@Url.Action("Home", "LimitTimeBuy", new { pageNo = 1, keywords = ViewBag.keywords, orderType = 2, orderKey = 1, catename=_item.Text })" onclick="">@(_item.Text)</a><b></b></dd>
                        }
                    </dl>
            </div>
        }

        @if (null != Model)
        {
            var count = ((PagingInfo)ViewBag.pageInfo).TotalPages;
            var curr = ((PagingInfo)ViewBag.pageInfo).CurrentPage;

            <div id="filter" style="margin-top:20px">
                <div class="fore1">
                    <dl class="order">
                        <dt>排序：</dt>
                        <dd class="@(ViewBag.orderKey == 1 ? "curr" : "")"><a href="@Url.Action("Home", "LimitTimeBuy", new { pageNo = 1, keywords = ViewBag.keywords, orderType =2, orderKey = 1 })" onclick="">默认</a><b></b></dd>
                        <dd class="@(ViewBag.orderKey == 2 ? "curr" : "")"><a href="@Url.Action("Home", "LimitTimeBuy", new { pageNo = 1, keywords = ViewBag.keywords, orderType =2, orderKey = 2 })">销量</a><b></b></dd>
                        <dd class="@(ViewBag.orderKey == 3 ? "curr" : "")"><a href="@Url.Action("Home", "LimitTimeBuy", new { pageNo = 1, keywords = ViewBag.keywords, orderType = ((int)ViewBag.orderType) == 2 ? 1 : 2, orderKey =3 })">价格</a><b></b></dd>
                    </dl>
                    <dl class="stock-search">
                        <dt>
                            <input class="text-stock-search" value="@ViewBag.keywords" id="searchVal" type="text" autocomplete="off" placeholder="搜索" />
                        </dt>
                        <dd>
                            <input class="btn-stock-search" id="ex-search" type="button" value="确定" />
                        </dd>
                    </dl>
                    <div class="pagin pagin-m" id="top_pagi"><span class="text"><i>@curr</i>/@count</span></div>
                    <span class="clr"></span>
                </div>

            </div>
            <div class="topic-goods time-sale">
                <ul class="cl">
                    @foreach (var item in Model)
                    {
                        <li>
                            <span class="tags">@item.Title</span>
                            <div class="p-img">
                                <a href="@Url.Action("Detail",new{id=item.Id})" target="_blank" title="">
                                    <img class="lazyload" src="~/Areas/Web/images/blank.gif" data-url="@item.ImagePath/1_220.png" />
                                </a>
                            </div>
                            <div class="p-name"><a href="@Url.Action("Detail",new{id=item.Id})" target="_blank" title="">@item.ProductName</a></div>
                            <p>@item.ProductAd</p>
                            <div class="p-price">￥@item.Price<s>￥@item.MinPrice</s></div><a href="@Url.Action("Detail",new{id=item.Id})" target="_blank" class="btn-buy">立即抢购</a>
                        </li>
                    }

                </ul>
            </div>

            <div class="m clearfix" id="bottom_pager">
                <div id="pagin-btm" class="pagin fr">
                    @Html.PageLinks((PagingInfo)ViewBag.pageInfo, x => Url.Action("home", new { pageNo = x, keywords = ViewBag.keywords, exp_keywords = ViewBag.exp_keywords, cid = ViewBag.cid, b_id = ViewBag.b_id, a_id = ViewBag.a_id, orderType = ViewBag.orderType, orderKey = ViewBag.orderKey }))<span class="page-skip">
                        <em>&nbsp;&nbsp;共 @count 页&nbsp;&nbsp;&nbsp;&nbsp;到第</em>
                        <input class="jumpto" type="text" value="@curr" id="jumpInput">
                        <em>页</em>
                        <a class="btn-skipsearch" id="pageJump_LMT" href="javascript:;">确定</a>
                    </span>
                </div>
            </div>
        }
        else
        {
            <span>目前没有任何限时购活动</span>
        }
    </div>
</div>

<script type="text/javascript">
    $(function () {
        $("#pageJump_LMT").click(function () {
            var pageNo = parseInt($("#jumpInput").val());
            var pagecount = parseInt($("#pageCount").html());
            if (pageNo > pagecount || pageNo < 1) {
                //alert("请您输入有效的页码!");
                return;
            }
            if (isNaN(pageNo)) {
                pageNo = 1;
            }
            search_LMT(pageNo);
        });
        $("#ex-search").click(function () {
            search_LMT(1);
        });
        function search_LMT(pageNo) {
            var exp_keyWords = $("#searchVal").val();
            var orderType = getQueryString('orderType');
            var orderKey = getQueryString('orderKey');
            var url = "./home?pageNo=" + pageNo.toString();
            if (exp_keyWords) {
                url += "&keywords=" + exp_keyWords;
            }
            if (orderType) {
                url += "&orderType=" + orderType;
            }
            if (orderKey) {
                url += "&orderKey=" + orderKey;
            }
            location.href = url;
        }
    });
</script>
